package com.tedu.checkIn.controller;

import com.tedu.checkIn.pojo.dto.RecordParam;
import com.tedu.checkIn.pojo.dto.RecordQuery;
import com.tedu.checkIn.pojo.vo.RecordVO;
import com.tedu.checkIn.service.RecordService;
import com.tedu.common.response.JsonResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/v1/checkIn/record")
@Slf4j
public class RecordController {
    @Autowired
    RecordService recordService;

    @PostMapping("/save")
    public JsonResult saveRecord(RecordParam recordParam){
        log.debug("保存入住信息，参数={}",recordParam);
        recordService.saveRecord(recordParam);
        return JsonResult.ok();
    }

    @GetMapping("/select")
    public JsonResult getRecordList(RecordQuery recordQuery){
        log.debug("查询入住信息列表，参数={}",recordQuery);
        List<RecordVO> list=recordService.selectRecord(recordQuery);
        return JsonResult.ok(list);
    }

    @PostMapping("delete/{id}")
    public JsonResult deleteRecord(@PathVariable Integer id){
        log.debug("删除入住信息，参数={}",id);
        recordService.delete(id);
        return JsonResult.ok();
    }
}
